//
//  MSHotelCell.m
//  MSJD
//
//  Created by 箭军刘 on 2018/10/14.
//  Copyright © 2018年 xiangbo. All rights reserved.
//

#import "MSHotelCell.h"

#import "MSStarControl.h"

@interface MSHotelCell()

@property (weak, nonatomic) IBOutlet UIView *customContentView;


@property (weak, nonatomic) IBOutlet UIImageView *hotelIcon;
@property (weak, nonatomic) IBOutlet UILabel *hotelTitle;
@property (weak, nonatomic) IBOutlet UIView *hotelStarSuperView;
@property (weak, nonatomic) IBOutlet UILabel *hotelScoreLabel;
@property (weak, nonatomic) IBOutlet UILabel *hotelTypeLabel;
@property (weak, nonatomic) IBOutlet UILabel *hotelLocalLabel; // 附近地标标签
@property (weak, nonatomic) IBOutlet UILabel *hotelDistanceLabel; // 离当前位置的距离


@property (weak, nonatomic) IBOutlet UIButton *moreButton; // 更多按钮

@property (nonatomic, strong) MSStarControl *starControl;

@property (nonatomic, strong) MSFoodDetailData *data;

@end

@implementation MSHotelCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.hotelIcon.layer.cornerRadius = 5.0;
    self.hotelIcon.layer.masksToBounds = YES;
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hotelIconTap:)];
    self.hotelIcon.userInteractionEnabled = YES;
    [self.hotelIcon addGestureRecognizer:tap];
}

- (void)refreshHotelCellWithData:(MSFoodDetailData *)data isFilter:(BOOL)isFilter {
    if (isFilter) {
        self.moreButton.hidden = YES;
    }
    if (!data.itemName) {
        return;
    }
    if (!self.starControl) {
        self.starControl = [[MSStarControl alloc] initWithFrame:CGRectMake(0.f, 0.f, 80, 12) numberOfStars:5 image:@"star_favorite11" foreColor:nil backColor:nil];
        [self.hotelStarSuperView addSubview:self.starControl];
    }
    self.starControl.scorePercent = [data.score floatValue];
    [self.hotelIcon setImageWithURL:[NSURL URLWithString:[MSSafeObject stringInfo:data.img]] placeholder:nil];
    self.hotelTitle.text = [MSSafeObject stringInfo:data.itemName];
    self.hotelScoreLabel.text = [NSString stringWithFormat:@"%@", data.score];
    self.hotelLocalLabel.text = [MSSafeObject stringInfo:data.location];
    
    // FIXME:离当前所在位置的距离
//    self.hotelDistanceLabel.text = @"未知";
    // FIXME:当前酒店的价格
    self.hotelTypeLabel.text = [NSString stringWithFormat:@"%.1f/人", data.price.floatValue];
}


#pragma mark - XIB Response
// 更多按钮点击
- (IBAction)moreButtonClick:(id)sender {
    if (self.MoreButtonClickBlock) {
        self.MoreButtonClickBlock();
    }
}

#pragma mark - Event Response

- (void)hotelIconTap:(UITapGestureRecognizer *)tap {
    UIImageView *hotelIcon = (UIImageView *)(tap.view);
    [MSImageFullScreenManager scanBigImageWithImageView:hotelIcon];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
